/**
*	@brief This file defines the entry point on a windows platform.
*
*	@author William McVicar
*/

#ifdef PROTEIN_PLATFORM_WINDOWS

using namespace Protein;

int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
{
	if( !ProteinFramework::InitialiseEngine() )
		return 1;

	APPLICATION_CLASS* pApplication = new APPLICATION_CLASS;
	if( !pApplication->Initialise() )
		return 2;
	
  IRenderer& rendereref = renderer();

	MSG msg = {0};
	while( WM_QUIT != msg.message )
	{
		if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
		{
			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}
		else
		{
			rendereref.Render();
			ProteinFramework::Run();
			pApplication->Update();
		}
	}

	if( !pApplication->Shutdown() )
		return 3;

	if( !ProteinFramework::UninitialiseEngine() )
		return 4;

	return (int)msg.wParam;
}

#endif

